package com.mysafe.provision.model.cycle;

import javax.inject.Inject;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.mysafe.provision.model.cycletype.CycleType;
import com.mysafe.provision.model.intervaltype.IntervalType;

@Entity
@Table(schema = "sfe", name = "en_cycle")
@SequenceGenerator(schema = "sfe", name = "seq_en_cycle", allocationSize = 1)
public class Cycle {
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_en_cycle")
	@Column(name = "id_cycle")
	private Integer id;
	
	@Column(name = "interval_value")
	private Integer intervalValue;
	
	@ManyToOne(cascade = CascadeType.REFRESH)  
    @JoinColumn(name = "id_interval_type")  
	private IntervalType intervalType;
	
	@ManyToOne(cascade = CascadeType.REFRESH)  
    @JoinColumn(name = "id_cycle_type")
	private CycleType cycleType;

	public Cycle() {
	}
	
	@Inject
	public Cycle(CycleType cycleType, IntervalType intervalType) {
		this.cycleType = cycleType;
		this.intervalType = intervalType;
	}
	
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getIntervalValue() {
		return this.intervalValue;
	}

	public void setIntervalValue(Integer intervalValue) {
		this.intervalValue = intervalValue;
	}

	public IntervalType getIntervalType() {
		return this.intervalType;
	}

	public void setIntervalType(IntervalType intervalType) {
		this.intervalType = intervalType;
	}

	public CycleType getCycleType() {
		return this.cycleType;
	}

	public void setCycleType(CycleType cycleType) {
		this.cycleType = cycleType;
	}
}